﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

public partial class DoiVe : System.Web.UI.Page
{
    Controllers controller;
    protected void Page_Load(object sender, EventArgs e)
    {
        controller = new Controllers();
        if (!IsPostBack)
        {
            Label1.Visible = false;
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        string MaDatVe = TextBox1.Text;
        List<string> list = controller.LayThongTinHuyVe2(MaDatVe);
        if (list.Count == 4)
        {
            DataTable dt = controller.LayThongTinKhach(list[2]);
            if(dt!=null)
            {
                foreach (DataRow dr in dt.Rows)
                {
                    DropDownList2.SelectedIndex = int.Parse(list[3])-1;
                    TextBox2.Text = (dr["hoTen"].ToString());
                    TextBox4.Text = (dr["soThe"].ToString());
                    DateTime ngayHetHan = DateTime.Parse(dr["ngayHetHan"].ToString());
                    TextBox9.Text = ngayHetHan.Month + "/" + ngayHetHan.Day + "/" + ngayHetHan.Year;
                    DateTime ngaySinh = DateTime.Parse(dr["ngaySinh"].ToString());
                    TextBox10.Text = ngaySinh.Month + "/" + ngaySinh.Day + "/" + ngaySinh.Year;
                    TextBox5.Text = (dr["soDienThoaiDiDong"].ToString());
                    TextBox55.Text = (dr["soDienThoaiBan"].ToString());
                    TextBox6.Text = (dr["email"].ToString());
                    break;
                }
            }
        }
        else
        {
            Label1.Visible = true;
            Label1.Text = "Không tìm thấy vé theo mã đã nhập";
            Label1.ForeColor = System.Drawing.Color.Red;
        }
    }
}